package cn.yh.register.hosp.controller;


import cn.yh.register.common.result.Result;
import cn.yh.register.hosp.service.ScheduleService;
import cn.yh.register.model.hosp.Schedule;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


@Api(tags = "排班管理接口")
@RestController
//@CrossOrigin
@RequestMapping("/admin/hosp/schedule")
public class ScheduleController {


    @Autowired
    private ScheduleService scheduleService;

    @ApiOperation("根据医院编号&科室编号分页查询排班数据")
    @GetMapping("/getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result<Map<String, Object>> getScheduleRule(@PathVariable Integer page,@PathVariable Integer limit,
                                    @PathVariable String hoscode,@PathVariable String depcode){
        Map<String, Object> hospSchedule = scheduleService.getHospSchedule(hoscode, depcode, page, limit);
        return Result.ok(hospSchedule);
    }

    @ApiOperation("获取某天的排班详情")
    @GetMapping("/getScheduleDetail/{hoscode}/{depcode}/{workDate}")
    public Result<List<Schedule>> getDetailSchedule(@PathVariable String hoscode,
                                                    @PathVariable String depcode,
                                                    @PathVariable String workDate){
        List<Schedule> scheduleList = scheduleService.getDetailSchedule(hoscode, depcode, workDate);
        return Result.ok(scheduleList);
    }
}
